package com.sunmouse.toolkit.fragment.custom;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sunmouse.toolkit.R;

/**
 * A simple {@link Fragment} subclass.
 * ——ViewDragHelp perfect wonderful for dragging a simple view，so if you want to drag multi views,you can
 * create the same num ViewDragHelper instance
 * <p/>
 * ——How to  use it?
 * 》using ViewDragHelper create(ViewGroup forParent, float sensitivity, Callback cb)  to create an instance
 * 》if you want toggle it by edge ,you should set setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT/ViewDragHelper.EDGE_RIGHT)
 * 》setMinVelocity(float minVel) ;
 * 》for all dragging operation are being completed in ck ,you should create a subclass (extends ViewDragHelper.CallBack)
 * and override some necessary methods
 * -->>Edge Toggling event (eg:left):
 * ----first: Override onEdgeTouched(in CallBack);
 * ----second: course,you should set setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT/ViewDragHelper.EDGE_RIGHT) first.
 * ----third:then,you will toggle a edge touch event when you touch the left screen
 * <p/>
 * -->>drag view to the specified position
 * ----First:Override tryCaptureView(View child, int pointerId) return child=dragView;//tell DragHelp the child is the
 * specific one when child== dragView;//dragView is the one you want to drag it.
 * ----Second:set dragging range  getViewHorizontalDragRange(View child) usually return child.width
 * ----Third:Clamping current position using for dragging it to there  clampViewPositionHorizontal(View child, int left, int dx)
 * <p/>
 * <p>
 * -->>handle release event
 * ----First:onViewPositionChanged(View changedView, int left, int top, int dx, int dy) { Override it and calculate
 * an offset(use for deciding dragView should scroll to primary point or object point)}
 * ----Second:onViewReleased(View releasedChild, float xvel, float yvel){handle scroll animation}
 * </p>
 * 》at last:tell DragHelper handle event more efficiently or intercepting some event;
 * you should dispatch events to DragHelp:
 * ---->shouldInterceptTouchEvent(ev)   invoked in onInterceptTouchEvent(MotionEvent ev)
 * ---->processTouchEvent(event)   invoked in onTouchEvent(MotionEvent ev)
 *
 * don`t forget:know more by reading some demo
 */
public class DraggingFragment extends Fragment {


    public DraggingFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_dragging, container, false);
    }

}
